package codegen;

public class ArrayDescr extends AbstractDescr {

    private static final long serialVersionUID = 1L;
    private int numberelems, startAddr;
    private AbstractDescr basetype;

    public ArrayDescr(int elemCount, AbstractDescr base) {
        super(elemCount * base.getSize());
        numberelems = elemCount;
        basetype = base;
    }

    public int GetNumberelems() {
        return numberelems;
    }

    public AbstractDescr GetBasetype() {
        return basetype;
    }

    public void print() {
        trace("ArrayDescr: numberelems: " + numberelems
                + " size: " + size);
        basetype.print();
        unindent();
    }

    @Override
    public String toString() {
        return "Array[" + numberelems + "," + basetype + "]" + super.toString();
    }

    @Override
    protected boolean equals(AbstractDescr descr) {
        if (descr instanceof ArrayDescr) {
            ArrayDescr ary = (ArrayDescr) descr;
            return (this.size == ary.size) && (this.basetype.equals((Object)ary.basetype));
        }
        return false;
    }
}
